#include "RsGisLibSegDropSeleClumps.h"
#include "ExtensionManager.h"
#include "ExtensionSession.h"
#include <QVariant>

RsGisLibSegDropSeleClumps::RsGisLibSegDropSeleClumps(RsgisPortal* ClientPortal, QWidget *parent)
{
	ui = new Ui::RsGisLibSegDropSeleClumps();
	ui->setupUi(this);

	Portal = ClientPortal;

	connect(ui->pushButton_ClumpsFilePath, SIGNAL(clicked()), this, SLOT(on_action_Button_ClumpsFilePath_clicked()));
	connect(ui->pushButton_OutputFilePath, SIGNAL(clicked()), this, SLOT(on_action_Button_OutputFilePath_clicked()));
	connect(ui->pushButton_Execute, SIGNAL(clicked()), this, SLOT(on_action_Button_Execute_clicked()));

	ui->lineEdit_ClumpsFilePath->setText("D:\\RS-RPC\\TEST\\IN\\RsGisLib\\In");
	ui->lineEdit_OutputFilePath->setText("D:\\RS-RPC\\TEST\\IN\\RsGisLib\\Out");

	ui->lineEdit_SelClumpsCol->setText("Sel");
	ui->lineEdit_GdalFormat->setText("GIFF");

	ui->lineEdit_Priority->setText("16");
}

void RsGisLibSegDropSeleClumps::on_action_Button_ClumpsFilePath_clicked()
{
	QString str = QFileDialog::getOpenFileName(this, "File Explorer", QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "All file(*.*)");
	ui->lineEdit_ClumpsFilePath->setText(str.toUtf8());
}

void RsGisLibSegDropSeleClumps::on_action_Button_OutputFilePath_clicked()
{
	QString str = QFileDialog::getSaveFileName(this, "File Explorer", QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "All file(*.*)");
	ui->lineEdit_OutputFilePath->setText(str.toUtf8());
}

void RsGisLibSegDropSeleClumps::on_action_Button_Execute_clicked()
{
	QList<QVariant> SysParaList;
	SysParaList << QVariant(QString("RsGisLib"));
	SysParaList << QVariant(QString("Segmentation"));
	SysParaList << QVariant(int(ui->lineEdit_Priority->text().toInt()));

	QList<QVariant> AlgParaList;
	AlgParaList << QVariant(QString("DropSeleClumps"));
	AlgParaList << QVariant(QString(ui->lineEdit_ClumpsFilePath->text()));
	AlgParaList << QVariant(QString(ui->lineEdit_OutputFilePath->text()));
	AlgParaList << QVariant(QString(ui->lineEdit_GdalFormat->text()));
	AlgParaList << QVariant(QString(ui->lineEdit_SelClumpsCol->text()));

	QVariantList ArgList;
	ArgList << (QVariant)SysParaList;
	ArgList << (QVariant)AlgParaList;

	Portal->goAhead(ArgList);
}